
/*     */ package com.openbravo.pos.forms;
/*     */ 
/*     */ import com.openbravo.basic.BasicException;
/*     */ import java.awt.BorderLayout;
/*     */ import java.awt.Component;
/*     */ import java.awt.GridLayout;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JComponent;
/*     */ import javax.swing.JPanel;
/*     */ 
/*     */ public class JPanelMenu extends JPanel
/*     */   implements JPanelView
/*     */ {
/*     */   private MenuDefinition m_menu;
/*  34 */   private boolean created = false;
/*     */ 
/*  95 */   private JPanel currententrypanel = null;
/*     */   private JPanel menucontainer;
/*     */ 
/*     */   public JPanelMenu(MenuDefinition menu)
/*     */   {
/*  39 */     this.m_menu = menu;
/*  40 */     this.created = false;
/*     */ 
/*  42 */     initComponents();
/*     */   }
/*     */ 
/*     */   public JComponent getComponent() {
/*  46 */     return this;
/*     */   }
/*     */ 
/*     */   public String getTitle() {
/*  50 */     return this.m_menu.getTitle();
/*     */   }
/*     */ 
/*     */   public void activate() throws BasicException
/*     */   {
/*  55 */     if (!this.created)
/*     */     {
/*  57 */       for (int i = 0; i < this.m_menu.countMenuElements(); i++) {
/*  58 */         MenuElement menuitem = this.m_menu.getMenuElement(i);
/*  59 */         menuitem.addComponent(this);
/*     */       }
/*  61 */       this.created = true;
/*     */     }
/*     */   }
/*     */ 
/*     */   public boolean deactivate() {
/*  66 */     return true;
/*     */   }
/*     */ 
/*     */   public void addTitle(Component title)
/*     */   {
/*  71 */     this.currententrypanel = null;
/*     */ 
/*  73 */     JPanel titlepanel = new JPanel();
/*  74 */     titlepanel.setLayout(new BorderLayout());
/*  75 */     titlepanel.add(title, "Center");
/*  76 */     titlepanel.applyComponentOrientation(getComponentOrientation());
/*     */ 
/*  78 */     this.menucontainer.add(titlepanel);
/*     */   }
/*     */ 
/*     */   public void addEntry(Component entry)
/*     */   {
/*  83 */     if (this.currententrypanel == null) {
/*  84 */       this.currententrypanel = new JPanel();
/*  85 */       this.currententrypanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0));
/*  86 */       this.currententrypanel.setLayout(new GridLayout(0, 3, 5, 5));
/*  87 */       this.menucontainer.add(this.currententrypanel);
/*     */     }
/*     */ 
/*  90 */     this.currententrypanel.add(entry);
/*  91 */     this.currententrypanel.applyComponentOrientation(getComponentOrientation());
/*     */   }
/*     */ 
/*     */   private void initComponents()
/*     */   {
/* 104 */     this.menucontainer = new JPanel();
/*     */ 
/* 106 */     setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
/* 107 */     setLayout(new BorderLayout());
/*     */ 
/* 109 */     this.menucontainer.setLayout(new BoxLayout(this.menucontainer, 1));
/* 110 */     add(this.menucontainer, "North");
/*     */   }
/*     */ }

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.forms.JPanelMenu
 * JD-Core Version:    0.6.0
 */